package com.my.study;

import java.util.*;

/**
 * 2个n位的m进制数
 */
public class MyMain {


    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int [] input1 = new int[n];
            int [] input2 = new int[n];
            for(int i =0;i < n;i++){
                input1[i] = scanner.nextInt();
            }
            for(int i =0;i < n;i++){
                input2[i] = scanner.nextInt();
            }
            Arrays.sort(input1);
            Arrays.sort(input2);

            Map<Integer, String> map = new HashMap<>();
            for(int i = 0;i < n;i++){
                for(int j =0;j<n;j++){
                    int val = (input1[i] + input2[j]) % m;
                    if(!map.containsKey(val)){
                        map.put((input1[i] + input2[j]) % m, i+"_" +j);
                    }else{
                        map.put(val, map.get(val) + ", " + i+"_" +j);
                    }
                }
            }
            int [] res = new int[n];
            int index = 0;
            boolean [] flag1 = new boolean[n];
            boolean [] flag2 = new boolean[n];
            for(int i = m-1;i >= 0;i--){
                if(map.containsKey(i)){
                    String val = map.get(i);
                    String[] group = val.split(",");
                    for(int j = 0;j < group.length;j++){
                        String[] tmp = group[j].split("_");
                        //System.out.println("tmp====" + tmp[0] + " ----" + tmp[1]);
                        if(!flag1[Integer.parseInt(tmp[0].trim())] && !flag2[Integer.parseInt(tmp[1].trim())]){
                            flag1[Integer.parseInt(tmp[0].trim())] = true;
                            flag2[Integer.parseInt(tmp[1].trim())] = true;
                            res[index] = i;
                            index++;
                        }
                    }
                }
            }
            for(int i =0;i < n;i++){
                System.out.print(res[i] + " ");
            }
        }
    }
}

